﻿#region Usings
using BK.Model;
using BK.Repositories.Abstract;
#endregion

namespace BK.BlusinessLogic
{
    public class BestExpensesBl : BaseExpensesBl<BestExpense, BestExpensesFile>
    {
        #region C'tors
        public BestExpensesBl(IExpensesRepository<BestExpense> expensesRepository,
            IImportStatusesRepository importStatusesRepository,
            IAccountsRepository accountsRepository,
            IExpensesFilesRepository<BestExpense, BestExpensesFile> expensesFilesRepository,
            ICategoriesRepository categoriesRepository,
            ICurrenciesRepository currenciesRepository,
            ITargetsRepository targetsRepository,
            IPaymentsRepository paymentsRepository)
            : base(expensesRepository, importStatusesRepository, accountsRepository, expensesFilesRepository,
                categoriesRepository, currenciesRepository, targetsRepository, paymentsRepository)
        {
        }
        #endregion

        protected override Category GetRootCategory(User user, BestExpense expense)
        {
            return CategoriesBl.GetBy(user.Id, expense.Type, null);
        }

        protected override Category CreateCategory(User user, BestExpense expense)
        {
            return new Category
            {

                Name = expense.Type,
                Parent = null,
                User = user
            };
        }

        protected override Target CreateTarget(User user, BestExpense expense)
        {
            return new Target
            {

                Name = expense.Category,
                Parent = null,
                User = user
            };
        }

        protected override Target GetRootTarget(User user, BestExpense expense)
        {
            return TargetsBl.GetBy(user.Id, expense.Category, null);
        }

        protected override IExpensesFilesBl<BestExpense, BestExpensesFile> CreateExpensesFilesBl(IExpensesFilesRepository<BestExpense, BestExpensesFile> expensesFilesRepository)
        {
            return new BestExpensesFilesBl(expensesFilesRepository);
        }
    }
}